#ifndef __Base3DViewer_H__
#define __Base3DViewer_H__

#include "BaseViewer.h"
class Base3DViewer : public BaseViewer
{
public:
    Base3DViewer();
    ~Base3DViewer();
    virtual bool init();

public:
    void setCamera();
    void resetCamera();
    void updateCameraTransform();

protected:
    void onTouchsMovedThis(const std::vector<cocos2d::Touch*> &touchs, cocos2d::Event *event);
    void onMouseScrollThis(cocos2d::Event* event);
    void onMouseMovedThis(cocos2d::Event* event);
    void onKeyPressedThis(cocos2d::EventKeyboard::KeyCode keycode, cocos2d::Event *event);

    void trackball(cocos2d::Vec3 & axis, float & angle, float p1x, float p1y, float p2x, float p2y);
    float tb_project_to_sphere(float r, float x, float y);

protected:
    cocos2d::Camera *_camera;

    float _orginDistance;
    cocos2d::Vec3 _orginCenter;

    float _distance;
    float _trackballSize;
    cocos2d::Quaternion _rotation;
    cocos2d::Vec3 _center;
    cocos2d::Vec2 _preMouseLocation;
};

#endif // __Base3DViewer_H__
